<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
	<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
	<meta HTTP-EQUIV="Expires" CONTENT="0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>产品标识码查询</title>
<style type="text/css">
	@import "../dojo-release-1.5.0/dijit/themes/tundra/tundra.css";
	@import "../dojo-release-1.5.0/dojo/resources/dojo.css";
	@import "../dojo-release-1.5.0/dojox/grid/resources/tundraGrid.css";
</style>
<script type="text/javascript" src="../dojo-release-1.5.0/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
<script type="text/javascript" src="../framework/uiutil.js"></script>
<script type="text/javascript">
dojo.addOnLoad(function(){
	initProductSelect();
	dojo.connect(dojo.byId("productSelect"),"onblur",initCodeNameSelect);
});


//初始化产品选择列表
function initProductSelect(){
	dojo.xhrGet({
		 url:"../bkgrd/getProductList.do",
		 handleAs:"json",
		 load:function(response){
			 ps = [];
			 for(var i in response){
				 ps.push({value:response[i],name:response[i]});
			 }
			 D.initCombo("productSelect",ps)
		 }
	});
}


//初始化绑定码名称列表
function initCodeNameSelect(){
	var productName = D.getComboValue("productSelect");
	dojo.xhrPost({
		 url:"../bkgrd/getAllBindingCodeNameList.do",
		 preventCache:true,
		 content:{productName:productName},
		 handleAs:"json",
		 load:function(response){
			 ps = [];
			 for(var i in response){
				 ps.push({value:response[i],name:response[i]});
			 }
			 D.initCombo("codeNameSelect",ps)
		 }
	});
}

function query(){
	var productName = D.getComboValue("productSelect");
	var codeName = D.getComboValue("codeNameSelect");
	var code = dojo.byId("code").value;
	var idCode = dojo.byId("idCode").value;

	if(productName == ''){
		alert("请选择产品类型");
		return;
	}
	if(code == '' && idCode == ''){
		alert("请至少输入产品标识码和绑定码中的一个");
		return;
	}
	dojo.xhrPost({
		 url:"../bkgrd/queryProductBindingCode.do",
		 encoding : 'UTF-8',
		 preventCache:true,
		 content:{
			 productName:productName,
			 codeName:codeName,
			 code:code,
			 idCode:idCode
		 },
		 handleAs:"json",
		 load:function(response){
			if(response == ""){
				alert("没有结果，请检查查询条件。");
				return;
			}
			displayResult(response);
		 }
	});
}

function displayResult(resultList){
	D.fillTableData("grid",resultList);
}

//详细报告
function retrospect(){
	var item = D.getSelectedRowOfTable("grid")[0];
	if(item == null){
		alert("请至少选择表格中的一行");
	}
	window.open("testResultRetrospect.html?productName="+item["productName"]+"&idCode="+item["idCode"]);
}
</script>

<style type="text/css">
#grid{
	border:1px solid #333;
	width:100%;
	margin:10px;
	height:500px;
	font-size:0.9em;
}
</style>
</head>
<body class="tundra">

<table width="90%">
<tr><td>请选择产品类型：</td><td><select dojoType="dijit.form.ComboBox" id="productSelect" value="" required="true" ></select></td>
<td>产品标识码：</td><td><input type="text" dojoType="dijit.form.TextBox" id="idCode" size="30" trim="true" value=""/></td></tr>
<tr><td>绑定码类型：</td><td><select dojoType="dijit.form.ComboBox" id="codeNameSelect"></select></td>
<td>绑定码值：</td><td><input type="text" dojoType="dijit.form.ValidationTextBox" id="code" size="30" trim="true" value=""/></td></tr>

<tr><td colspan="4" align="center">
<button dojoType="dijit.form.Button" id="query" onclick="query()">查询产品</button>
<button dojoType="dijit.form.Button" id="retrospect" onclick="retrospect()">详细检测报告</button>
</td></tr>
</table>

<div>
<table dojoType="dojox.grid.DataGrid" id="grid"  autoWidth="true">
 <thead>
	<tr>
	     <th field="productName" width="100px">产品名称</th>
	     <th field="idCode" width="120px">产品标识码</th>
	     <th field="codeName" width="120px">绑定码</th>
	     <th field="code" width="120px">绑定码值</th>
	</tr>
</thead>
</table>
</div>


</body>
</html>